package com.itmate.wei.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.itmate.wei.entity.Statues;
import com.itmate.wei.service.StatuesService;

/**
 * Servlet implementation class DoUpdata
 */
@WebServlet("/DoUpdata")
public class DoUpdata extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public DoUpdata() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String id=request.getParameter("id");
		String inout = request.getParameter("inout");
		String money = request.getParameter("money");
		String date = request.getParameter("date");
		String family_id = request.getParameter("family_id");
		
		Statues sta=new Statues();
		sta.setId(Integer.parseInt(id));
		sta.setStatue(inout);
		sta.setMoney(Double.parseDouble(money));
		sta.setDate(date);
		sta.setFamily_id(Integer.parseInt(family_id));
		StatuesService p=new StatuesService();
		int i=p.UpdataStatues(sta);
		if(i>0){
			request.setAttribute("msa", "修改成功");
		}else{
			request.setAttribute("msa", "修改失败");
		}
		request.getRequestDispatcher("/toIndex").forward(request, response);
		
	}

		
	

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
 }
}